//拿supermarket补偿金额，需求改过，已经不用
function findCurrRetail(JSON_CSRL_LIST) {
    for (var i = 0; i < JSON_CSRL_LIST.length; i++) {
        if (JSON_CSRL_LIST[i].PRICE_TYPE != 'CS'
            && betweenDay(new Date(JSON_CSRL_LIST[i].EFFECTIVE_DATE), new Date(NEW_COST_EFF_DATE)) >= 0
            && betweenDay(new Date(NEW_COST_EFF_DATE), new Date(JSON_CSRL_LIST[i].EXPIRATION_DATE)) >= 0) {
            return JSON_CSRL_LIST[i].CUST_BASE_RTL_AMT;
        }
    }
    return 0;
}
//取当前成本
function findCurrCost(JSON_CSRL_LIST) {
    for (var i = 0; i < JSON_CSRL_LIST.length; i++) {
        if (JSON_CSRL_LIST[i].PRICE_TYPE == 'CS'
            && betweenDay(new Date(JSON_CSRL_LIST[i].EFFECTIVE_DATE), new Date(NEW_COST_EFF_DATE)) >= 0
            && betweenDay(new Date(NEW_COST_EFF_DATE), new Date(JSON_CSRL_LIST[i].EXPIRATION_DATE)) >= 0) {
            return JSON_CSRL_LIST[i].VNPK_PPD_COST_AMT;
        }
    }
    return 0;
}

function getRateAmountFromHY(NEW_CASE_COST, RETAIL, JSON_CSRL_LIST, ALLOWANCE_REQUEST_TYPE,RATE_AMOUNT) {
    //1新成本当天的现成本-新成本
    if (ALLOWANCE_REQUEST_TYPE == 1) {
        return findCurrCost(JSON_CSRL_LIST) - NEW_CASE_COST;
    }
    //2现生效零售-新零售
    else if (ALLOWANCE_REQUEST_TYPE == 2 || ALLOWANCE_REQUEST_TYPE == 3) {
        return findCurrRetail(JSON_CSRL_LIST) - NEW_CASE_COST;
    }else{
        return RATE_AMOUNT;
    }
}
